<template>
  <div class="chatsetting">
    <div class="chat-setting-top">
      <div class="head-left">
        <el-switch
            v-model="isCheck"
            active-color="#3070ff"
            inactive-color="#DCDFE6"
            class="switchStyle"
            :active-value="true"
            :inactive-value="false"
            active-text="开"
            inactive-text="关"
            @change="changeSwitch">
        </el-switch>
        <div class="title">客服聊天功能</div>
        <div class="desc" v-if="isCheck">主子账号充当客服参与多企微号消息分发，提高客服服务效率</div>
      </div>
      <div class="head-right" v-if="!isCheck">
        <i class="el-icon-warning-outline"></i>
        当前开关已关闭，请先开启开关规则设置才能生效
      </div>
    </div>
    <div class="flex">
      <div class="menulist bg_fff mr-16 p-16">
        <div class="f-16 fw-6 c_text2 mb-16">设置项</div>
        <div class="mlist">
          <div
            v-for="(item, index) in menuList"
            :key="index"
            class="menuitem f-14 flex aligncenter commhover"
            :class="{ active: active == item.id }"
            @click="handleItem(item.id)"
          >
            {{ item.name }}
          </div>
        </div>
      </div>
      <div class="pagemain bg_fff h_full">
        <page-one v-if="active == 1" />
        <page-two v-if="active == 2" />
        <page-three v-if="active == 3" />
        <page-four v-if="active == 4" />
        <page-five v-if="active == 5" />
        <page-six v-if="active == 6" />
        <page-seven v-if="active == 7" />
        <page-eight v-if="active == 8" />
        <page-nine v-if="active == 9" />
      </div>
    </div>
  </div>
</template>
<script>
import PageOne from "./PageOne.vue";
import PageTwo from "./PageTwo.vue";
import PageThree from "./PageThree.vue";
import PageFour from "./PageFour.vue";
import PageFive from "./PageFive.vue";
import PageSix from './PageSix.vue'
import PageSeven from './PageSeven.vue'
import PageEight from './PageEight.vue'
import PageNine from './PageNine.vue'

export default {
  data() {
    return {
      isCheck: true,
      menuList: [
        { id: 1, name: "对话接入上限" },
        { id: 4, name: "分配规则" },
        { id: 5, name: "分发条件" },
        { id: 6, name: "对话规则" },
        { id: 7, name: "自动回复" },
        { id: 8, name: "客服评价" },
        { id: 9, name: "其它设置" },
        { id: 2, name: "屏蔽对象" },
        { id: 3, name: "屏蔽关键词" },
      ],
      active: 4,
    };
  },
  components: {
    PageOne,
    PageTwo,
    PageThree,
    PageFour,
    PageFive,
    PageSix,
    PageSeven,
    PageEight,
    PageNine
  },
  methods: {
    handleItem(id) {
      this.active = id;
    },

    changeSwitch(val){
      console.log('val', val)
      if(!val){
        this.$msgBox
        .showMsgBox({
          title: "提示？",
          content: "功能关闭后，所有客服进行中、挂起、排队中、留言、结束的对话都会清空，聊天记录保留，确认关闭吗？",
        })
        .then(() => {
          delScriptGroup(row.id).then(() => {
            this.$message.success("删除成功!");
            this.getScriptGroupList();
          });
        })
        .catch(() => {});
      }
    }
  },
};
</script>
<style lang="scss" scoped>
.chatsetting {
  width: 1200px;
  margin: 20px auto;
  height: calc(100vh - 84px);
}
.chat-setting-top {
  height: 52px;
  background: #fff;
  border-radius: 4px;
  padding: 0 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .head-left {
    font-size: 14px;
    font-weight: 600;
    color: rgba(0, 0, 0, .85);
    line-height: 22px;
    display: flex;
    align-items: center;
    .title {
      margin-left: 12px;
    }
    .desc {
      font-size: 12px;
      font-weight: 400;
      color: rgba(0, 0, 0, .45);
      line-height: 20px;
      margin: 0 0 0 8px;
    }
  }
  .head-right {
    color: red;
    font-size: 14px;
    line-height: 22px;
  }
}
.menulist {
  width: 200px;
  box-shadow: 1px 0 0 0 #f0f0f0;
  border-radius: 4px;
}
.menuitem {
  position: relative;
  height: 32px;
  padding: 0 12px;
  margin-bottom: 5px;
  border-radius: 4px;
  &:hover {
    background-color: #fafafa;
  }
  &.active {
    background-color: #ebf2ff;
  }
}
.pagemain {
  width: 984px;
  height: calc(100vh - 150px);
  border-radius: 4px;
  padding: 16px 16px 0;
  overflow-x: hidden;
  overflow-y: auto;
}

::v-deep .el-switch__label {
  position: absolute;
  display: none;
  color: #fff;
}
/*打开时文字位置设置*/
::v-deep .el-switch__label--right {
  z-index: 1;
  right: 20px;
}
/*关闭时文字位置设置*/
::v-deep .el-switch__label--left {
  z-index: 1;
  left: 20px;
}
/*显示文字*/
::v-deep .el-switch__label.is-active {
  display: block;
}
::v-deep .el-switch .el-switch__core,
.el-switch .el-switch__label {
  width: 44px;
}
</style>